The first thing to know about JavaScript's automatic conversion is what type it needs, so JavaScript automatically passes the current type to the constructor of the required type to generate the required typeGuess 1:undefined is a class estimate in
Usually in the following statement structure to determine the true and false
If branch statement
While Loop statement
For the second statement in the
Such as
Copy Code code as follows:
if (boo) {
Do something
}
while (Boo)
This article mainly introduces the false value application of the wonderful flower in JavaScript, the friend who need can refer to the following Usually in the following statement structure needs to determine true and false If branch
1. Value of Ture or FalseThe value of the Boolean type that will be implicitly converted to false in the If judgment has false, 0, undefined, null, ' ', NaN (not a number)Besides the other values will be considered true, including ' 0 ', ' false ',
The operation of a computer program needs to operate on values such as the number 3.14 or the text "Hello World", where the type of value that can be represented and manipulated is called the data type (type), and the most basic feature of a
False, zero, null, undefined, and empty string objects in Javascript
In Javascript, We often come into contact with the five special objects mentioned in the question -- false, 0, empty string, NullAnd undefined. These objects are easy to use
JavaScript checks original values, reference values, attributes, and javascript
In JavaScript, we often see code like this: the comparison between variables and null (this usage is very problematic) is used to determine whether a variable is given a
In JavaScript, we are often exposed to the 5 more special objects mentioned in the topic--false, 0, empty strings, null, and undefined. These objects are easy to use, so you have to be careful when you use them.Type detectionLet's come down and see
1, [0,nan, "", null,undefined] can be converted directly to false, but these values are not exactly equal1 vararr = [0, "",false,NULL, Undefined,nan]2 for(vari=0;i){3 for(varj=i;j){4 if(arr[i]==Arr[j]) {5Console.log
True and false values
All values in javascript can be implicitly converted to the boolean type.
In condition determination, the following values are automatically converted to false:
Null, undefined, Nan, 0, '', false
Therefore, you do not need
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.